#
# Make file to build the IBM DB2 Database Driver for DBConnect API
# Copyright (c) Johnathan Ingram 2003, jingram@rogueware.org
#
# dynamic: Build the driver requiring the IBM DB2 dynamic link library.
#          There is no support for static linking for DB2
#
#####################################################################

SHELL = /bin/sh

top_srcdir = ../..
CC = gcc
CXX = g++
CPPFLAGS = 
CFLAGS = -fPIC $(CPPFLAGS) -g -O2 -DLINUX -DDBCONNECTVER='"0.3.5"'
LINKER_FLAGS = 
IFLAGS = -I../base -I/home/db2inst1/sqllib/include

SOURCES = ibmDB2Connection.cpp ibmDB2Query.cpp ibmDB2BindParam.cpp ibmDB2Value.cpp ibmDB2FieldDescription.cpp
LIB_OBJS = $(SOURCES:.cpp=.o)
LIB_OBJS += main_so.o

all: 
	cp -f ./dbconndrv-ibmDB2-0.3.5.so $(top_srcdir)/lib/drivers
	cd $(top_srcdir)/lib/drivers && ln -sf dbconndrv-ibmDB2-0.3.5.so dbconndrv-ibmDB2.so && cd -


dynamic: $(LIB_OBJS)
	gcc -shared $(LINKER_FLAGS) \
	-o dbconndrv-ibmDB2-0.3.5.so $(LIB_OBJS) \
	-ldl -lpthread  -L/home/db2inst1/sqllib/lib -l \
	-L../dbconnect -ldbconnect-0.3.5

clean:
	rm -f *.o
	rm -f *.so
	rm -f $(top_srcdir)/lib/drivers/dbconndrv-ibmDB2-0.3.5.so


main_so.o: main_so.cpp
	$(CXX) -c main_so.cpp $(CFLAGS) $(IFLAGS) -o main_so.o


%.o: %.cpp %.h
	$(CXX) -c $< $(CFLAGS) $(IFLAGS) -o $@
